package com.gitee.loyo;

import io.vertx.core.Future;
import io.vertx.core.Vertx;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.json.Json;

import java.util.ArrayList;
import java.util.List;

public class BridgeConfig {
    public transient static BridgeConfig INSTANCE;

    public boolean basicAuthEnabled = false;
    public String basicAuthUsername = null;
    public String basicAuthPassword = null;
    public List<Bridges.Bridge> bridges = new ArrayList<>();
    public List<Endpoints.Proxy> proxies = new ArrayList<>();
    public List<Jumpers.Jumper> jumpers = new ArrayList<>();

    public Future<Void> save(){
        String data = Json.encodePrettily(this);
        return Vertx.currentContext().owner().fileSystem().writeFile(Global.BRIDGE_FILE.getPath(), Buffer.buffer(data));
    }
}
